package org.jivesoftware.smack.packet;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class DefaultPacketExtension
  implements PacketExtension
{
  private String elementName;
  private Map<String, String> map;
  private String namespace;

  public DefaultPacketExtension(String paramString1, String paramString2)
  {
    this.elementName = paramString1;
    this.namespace = paramString2;
  }

  public String getElementName()
  {
    return this.elementName;
  }

  /**
   * @deprecated
   */
  public Collection<String> getNames()
  {
    Set localSet1;
    Object localObject2;
    monitorenter;
    try
    {
      if (this.map == null)
      {
        Set localSet2 = Collections.emptySet();
        localObject2 = localSet2;
        monitorexit;
        return localObject2;
      }
      localSet1 = Collections.unmodifiableSet(new HashMap(this.map).keySet());
    }
    finally
    {
      monitorexit;
    }
  }

  public String getNamespace()
  {
    return this.namespace;
  }

  /**
   * @deprecated
   */
  public String getValue(String paramString)
  {
    String str;
    monitorenter;
    try
    {
      Map localMap = this.map;
      if (localMap == null)
      {
        str = null;
        monitorexit;
        return str;
      }
    }
    finally
    {
      monitorexit;
    }
  }

  /**
   * @deprecated
   */
  public void setValue(String paramString1, String paramString2)
  {
    monitorenter;
    try
    {
      if (this.map == null)
        this.map = new HashMap();
      this.map.put(paramString1, paramString2);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<").append(this.elementName).append(" xmlns=\"").append(this.namespace).append("\">");
    Iterator localIterator = getNames().iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        localStringBuilder.append("</").append(this.elementName).append(">");
        return localStringBuilder.toString();
      }
      String str1 = (String)localIterator.next();
      String str2 = getValue(str1);
      localStringBuilder.append("<").append(str1).append(">");
      localStringBuilder.append(str2);
      localStringBuilder.append("</").append(str1).append(">");
    }
  }
}